public class Jump {
    public int jump(int[] nums) {
        int curRight=0;
        int nextRight=0;
        int ans=0;
        for (int i = 0; i < nums.length-1; i++) {
            //每次选最大的跳跃
            nextRight=Math.max(nextRight,nums[i]+i);
            if(i==curRight){
                curRight=nextRight;
                ans++;
            }
        }
        return ans;
    }
}
